<%--
 *  File:    DataAfterClean4Inv.jsp
 *  @Author: Jamesli
 *  Date:    2010/07/21
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.DataAfterClean4Inv"); 

  //init param
  String strModuleName = "CM";
  String privilegeCode = "E0211";
  String contextPath = request.getContextPath();
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>DataAfterClean4Inv</title>
<PageFlow:CheckPageFlow pageName="p_dataafterclean4inv"/>
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<%
Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
if(totalsummary == null) totalsummary = new Vector();
	String subData = (String)pageContext.getAttribute("datafrequency");
	
	%>


<script>
function page_checkall(){
	var allcheck = cform.checkall;
	var allfile = document.getElementsByName("fileids");
	for(var i = 0 ; i < allfile.length;i++){
		allfile[i].checked = allcheck.checked;
	}
}

function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  editform.action = "DataAfterClean4Inv.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}

function page_detail(id){
  self.location.href = "DataAfterCleanDetail.jsp?<%= OvalTools.randomURL() %>&datafileid=" + id + "&processtype=" + 20;
}

var popwindow;


function page_setRegion(code,name)
{
  if(code != document.cform.regioncode.value)
  {
    document.cform.citycode.value = "";
    document.cform.cityname.value = "";
  }
  document.cform.regioncode.value = code;
  document.cform.regionname.value = name;
  if (popwindow != null)
    popwindow.close();
}

function page_selectProvince()
{
  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open('<%=contextPath %>/masterdata/ogm/RegionSelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN','newwindow', 'height=250, width=500,top=100,left=100,toolbar=n0, menubar=no, scrollbars=no, resizable=no, location=no, status=no');
}

function page_selectCity()
{
  var regioncode = document.cform.regioncode.value;
  if(regioncode=="" || regioncode==-1)
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
    return;
  }
  if(popwindow!=null)
    popwindow.close();
  popwindow = window.open('<%=contextPath %>/masterdata/ogm/CitySelect.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN&regioncode=' + regioncode,'newwindow', 'height=250, width=400,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no');
}

function page_setCity(code,name)
{
  document.cform.citycode.value = code;
  document.cform.cityname.value = name;
  if (popwindow != null)
    popwindow.close();
}

function page_setOrg(id,name,code)
{
  document.cform.parternerid.value = id;
  document.cform.parternercode.value = code;  
  document.cform.parternername.value = name;
  var remote = window.open("","newwindow");
  if (remote != null)
    remote.close();
}


function page_changeRegion()
{
	var regioncode = cform.regioncode.value;
	page_cleanregionandcity();
	if(regioncode == "")return;
   var datahandler = new  DataHandler() ;
   datahandler.add_params("regioncode" , regioncode, 'String') ;
   datahandler.add_params("languagecode" , document.cform.languagecode.value, 'String') ;
   datahandler.getResult("regionname" ,"document.cform.regionname");
   datahandler.add_job("j_getregionbycode");
   datahandler.add_function("page_checkRegion()");
   datahandler.runDataHandler();
}

function page_checkRegion(){
	if(cform.regionname.value == ""){
		cform.regioncode.value = "";
	}
}

function page_changeCity()
{
	var regioncode = cform.regioncode.value;
	var citycode = cform.citycode.value;
	if(isEmpty(regioncode))
	{
	  alert("<%= message.getMessageDesc("MUST_SELECT_FIRST",label.getLabelName("L_Province"))%>");
	  cform.citycode.value = "";
	  return;
	}
	page_cleancity();
	if(regioncode == "")return;
	if(citycode == "" || citycode == null) return;
	var datahandler = new  DataHandler() ;
	datahandler.add_params("regioncode" , regioncode, 'String') ;
	datahandler.add_params("citycode" , citycode, 'String') ;
	datahandler.add_params("languagecode" , document.cform.languagecode.value, 'String') ;
	datahandler.getResult("cityname" ,"document.cform.cityname");
	datahandler.add_job("j_getcitybycode");
	datahandler.add_function("page_checkCity()");
	datahandler.runDataHandler();
}

function page_checkCity(){
	if(cform.cityname.value == ""){
		cform.citycode.value = "";
	}
}

function page_changeOrg()
{
	var parternercode = cform.parternercode.value;
	cform.parternername.value = "";
	cform.parternerid.value = "";
	if(parternercode == "")return;
	var datahandler = new  DataHandler() ;
	datahandler.add_params("orgcode" , parternercode, 'String') ;
	datahandler.getResult("orgname" ,"document.cform.parternername");
	datahandler.getResult("orgid" ,"document.cform.parternerid");
	datahandler.add_job("j_getorgbycode");
	datahandler.add_function("page_checkOrg()");
	datahandler.runDataHandler();
}

function page_checkOrg(){
	if(cform.parternerid.value == ""){
		cform.parternername.value = "";
		cform.parternercode.value = "";
	}
}

function page_cleanregionandcity(){
 	cform.regionname.value = "";
 	cform.citycode.value = "";
 	cform.cityname.value = "";
 }

 function page_cleancity(){
 	cform.cityname.value = "";
 }

function hasChecked(){
	var allfile = document.getElementsByName("fileids");
	var idstr = "";
	for(var i = 0 ; i < allfile.length;i++){
		if(allfile[i].checked){
			idstr += "&fileids=" + allfile[i].value;
		}
	}
	if(idstr == ""){
		alert("<%= message.getMessageDesc("PLEASE_SELECT")%>");
		return false;
	}
	return true;
}
function page_import(){
	if(!hasChecked()) return;
	cform.actionname.value = "import";
	cform.target = "_self";
	isRunning = true;
	cform.submit();
}

function page_statusback(){
	if(!hasChecked()) return;
	cform.actionname.value = "statusback";
	cform.target = "_self";
	isRunning = true;
	cform.submit();
}


</script>
</head>
<body >
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_dataafterclean4inv">
	<input type="hidden" name="actionname">

	<%if(subData.equals("M") || subData.equals("D")){%>
	<custom:hidden property="datatype" value="20"></custom:hidden>
	<%}else if(subData.equals("W")){%>
	<custom:hidden property="datatype" value="50"></custom:hidden>
    <%}else{%>
	<custom:hidden property="datatype" value="80"></custom:hidden>
	<%}%>
	<custom:hidden property="languagecode" scope="session"/>
	<custom:hidden property="datafrequency"></custom:hidden>
   <tr>
    <td> 
      <table width="100%" border="0" cellspacing="0"  onkeydown="if(event.keyCode==13) page_summary('search');">  
         <tr>
          	<td class="td_right"><%= label.getLabelName("L_Province") + label.getLabelName("L_Colon") %></td>
            <td>
            	<custom:text property="regioncode" name="conditionmap" command="notnull" label="L_Province" size="10" onchange="page_changeRegion()"/>
            	<a onclick="javascript:page_selectProvince();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            	<custom:text property="regionname" name="conditionmap" readonly="true" size="20"/>
            </td>
         	<td class="td_right"><%= label.getLabelName("L_City") + label.getLabelName("L_Colon") %></td>
          	<td>
          		<custom:text property="citycode" name="conditionmap" size="10" onchange="page_changeCity()"/>
            	<a onclick="javascript:page_selectCity();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            	<custom:text property="cityname" name="conditionmap" readonly="true" size="20"/>
            </td>
         </tr>
         <tr>
         	<td class="td_right" ><%= label.getLabelName("L_Partner") + label.getLabelName("L_Colon") %></td>
            <td>
            	<custom:text property="parternercode" name="conditionmap" size="10" onchange="page_changeOrg()"/>
            	<a onclick="popup('<%=contextPath %>/masterdata/ogm/OrgSelect.jsp?<%= OvalTools.randomURL() %>','newwindow','height=450, width=600,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no')"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
            	<custom:text property="parternername" name="conditionmap" readonly="true" size="20"/>
            	<custom:hidden property="parternerid" name="conditionmap"/>
            </td>
         	<td class="td_right"><%= label.getLabelName("L_filename") + label.getLabelName("L_Colon") %></td>
         	<td>
         		<custom:text name="conditionmap" property="filename" size="30"></custom:text>
         		<a href="javascript:page_summary('search')"><img src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif" border="0" style="border: 1 solid #000000"></a>
         	</td>
         </tr>
         
       </table>
    </td>
  </tr>
  <tr> 
    <td> 
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
         <tr  class="deepblue-left"> 
            <td width="5%" class="title_center"><custom:checkbox property="checkall" styleClass="checkbox" onclick="page_checkall()"/></td>
            <td width="*" class="title_center"><%= label.getLabelName("L_filename")%></td>
            <td width="20%" class="title_center"><%= label.getLabelName("L_Partner") %></td>
            <td width="15%" class="title_center"><%= label.getLabelName("L_BatchNumber") %></td>
            <td width="6%" class="title_center"><%= label.getLabelName("L_TotalData") %></td>
            <td width="6%" class="title_center"><%= label.getLabelName("L_DeleteNum") %></td>
            <td width="9%" class="title_center"><%= label.getLabelName("L_CheckStatus") %></td>
            <td width="9%" class="title_center"><%= label.getLabelName("L_AcceptDate") %></td>
         </tr>
         <%
             int j = 0;
             String strClassType = new String(); 
        
          %>
          <logic:iterate id="summary" collection="<%= totalsummary %>">                      
         <%
            HashMap summaryMap = (HashMap)pageContext.getAttribute("summary");
            if(summaryMap == null) summaryMap = new HashMap();
            String strIsChecked = new String("");
            
            if(j%2 == 1){
              strClassType = "td-listrom";             
            }else{                    
              strClassType = "";
            }
              
            j++;     
          %>
           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'" class="<%=JspHelper.filterNull(strClassType)%>">
            <td class="title_center">
              <custom:checkbox property="fileid" styleClass="checkbox" name="summary" changedName="fileids"/>
            </td>
            <td>&nbsp;<A onclick="page_detail('<custom:write property="fileid" name="summary"/>')"><custom:write property="filename" name="summary"/></A></td>
            <td>&nbsp;<custom:write property="shortname" name="summary"/></td>
            <td>&nbsp;<custom:write property="batchno" name="summary" nbsp="true"/></td>
            <td>&nbsp;<custom:write property="totalqty" name="summary" nbsp="true"/></td>
            <td>&nbsp;<custom:write property="deleteqty" name="summary" nbsp="true"/></td>
            <td>&nbsp;<custom:write property="checkstatus" name="summary" nbsp="true"/></td>
            <td>&nbsp;<custom:write property="receivedate" name="summary" nbsp="true" dataType="date" dataFormat="yyyy-MM-dd"/></td>
          </tr>
          </logic:iterate>
      <% //--------------------------------------  flipping page --%>
      <%@ include file="/inc/SummaryAction.inc" %>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr> 
          <td class="summary_top"></td>
        </tr>
        <%if(totalsummary.size() != 0) {%>
	        <tr> 
	          <td class="td_center">
	            <a onclick="page_import()"><custom:button type="1" label="L_ImportFormalTable" imgsrc="edit.gif" border="0" style="width:80"/></a>
	            <a onclick="page_statusback()"><custom:button type="1" label="L_StatusBack" imgsrc="delete.gif" border="0" style="width:80"/></a>
	          </td>
	        </tr>
        <%} %>
      </table>
    </td>
  </tr>
  </form>
</table>
</body>
</html>